<template>
  <a-modal
    v-model="visible"
    :title="modalTitle"
    cancelText="取消"
    okText="下一步"
    @cancel="cancel"
    width="70%"
    centered
  >
    <template slot="footer" class="modelBtn">
      <a-button @click="cancel">取消</a-button>
      <a-button v-if="activeKey == '2'" @click="goBack(modalFlag)"
        >上一步</a-button
      >
      <a-button type="primary" v-if="activeKey == '1'" @click="activeKey = '2'"
        >下一步</a-button
      >
      <a-button
        type="danger"
        v-if="activeKey == '2' && submitView != 'look'"
        @click="handleOk('no')"
        >不通过</a-button
      >
      <a-button
        type="primary"
        v-if="activeKey == '2' && submitView != 'look'"
        @click="handleOk('pass')"
        >通过</a-button
      >
      <a-popconfirm
        v-if="
          activeKey == '2' &&
          addForm.auditState == '4' &&
          addForm.isSendBill == null
        "
        title="确认无误并接收？"
        ok-text="确定"
        cancel-text="取消"
        @confirm="handleOk('sendBill')"
      >
        <a-button type="primary" :loading="loading">发送账单</a-button>
      </a-popconfirm>
      <a-button
        type="primary"
        v-if="
          activeKey == '3' &&
          addForm.auditState == '4' &&
          addForm.isSendBill != null
        "
        @click="cancel"
        >确认</a-button
      >
    </template>
    <a-tabs default-active-key="1" :activeKey="activeKey" @change="changeTab">
      <a-tab-pane key="1">
        <span slot="tab"> 1、基本信息 </span>
        <a-form-model
          class="zxmx"
          ref="addForm"
          :rules="addFormRules"
          :model="addForm"
        >
          <!-- 转运标题 -->
          <a-form-model-item prop="title" label="转运标题：">
            <a-input
            :maxLength="128"
              :disabled="modalFlag == 'info'"
              size="small"
              placeholder="转运标题"
              v-model="addForm.title"
            />
          </a-form-model-item>
          <!-- FBA ID -->
          <a-form-model-item
            prop="fbaId"
            label="FBA ID："
            style="width: 47% !important"
          >
            <a-input
            :maxLength="128"
              size="small"
              placeholder=""
              v-model="addForm.fbaId"
              :disabled="modalFlag == 'info'"
            />
          </a-form-model-item>
          <!-- REFERENCE ID -->
          <a-form-model-item
            prop="referenceId"
            label="REFERENCE ID："
            style="width: 47% !important"
          >
            <a-input
            :maxLength="128"
              :disabled="modalFlag == 'info'"
              size="small"
              placeholder=""
              v-model="addForm.referenceId"
            />
          </a-form-model-item>
          <!-- 出库仓库 -->
          <a-form-model-item
            prop="warehouseId"
            label="出库仓库："
            style="width: 47% !important"
          >
            <a-select
              :disabled="modalFlag == 'info'"
              size="small"
              show-search
              placeholder="请选择仓库"
              option-filter-prop="children"
              :filter-option="filterOption"
              @change="handleChangeWarehouse"
              v-model="addForm.warehouseId"
            >
              <a-select-option
                :value="item.warehouseId"
                v-for="item in warehouseData"
                :key="item.warehouseId"
                :name="item.titleName"
              >
                {{ item.titleName }}
              </a-select-option>
            </a-select>
          </a-form-model-item>
          <!-- 物流安排 -->
          <a-form-model-item
            prop="logisticsId"
            label="物流安排："
            style="width: 47% !important"
          >
            <a-select
              :disabled="modalFlag == 'info'"
              size="small"
              show-search
              option-filter-prop="children"
              :filter-option="filterOption"
              @change="ChangeWarehouses"
              v-model="addForm.logisticsId"
            >
              <a-select-option
                :value="item.key"
                v-for="item in warehouses"
                :key="item.key"
                :name="item.titleName"
              >
                {{ item.titleName }}
              </a-select-option>
            </a-select>
          </a-form-model-item>
          <!-- 收件地址类型 -->
          <a-form-model-item prop="addressType" label="收件地址类型：">
            <a-radio-group
              :disabled="modalFlag == 'info'"
              v-model="addForm.addressType"
            >
              <a-radio :value="1"> 自定义地址 </a-radio>
              <a-radio :value="2"> FBA地址 </a-radio>
            </a-radio-group>
          </a-form-model-item>
          <!-- 常用地址 -->
          <a-form-model-item
            prop="addressId"
            label="常用地址："
            v-if="addForm.addressType == '1'"
          >
            <a-input
            :maxLength="128"
              :disabled="modalFlag == 'info'"
              size="small"
              v-model="addForm.addressText"
            />
          </a-form-model-item>
          <!-- FBA仓库地址 -->
          <a-form-model-item
            prop="addressId"
            label="FBA仓库地址："
            v-if="addForm.addressType == '2'"
          >
            <a-input
            :maxLength="128"
              :disabled="modalFlag == 'info'"
              size="small"
              v-model="addForm.addressText"
            />
          </a-form-model-item>
          <!-- 公司名称 -->
          <a-form-model-item prop="companyTitle" label="公司名称：">
            <a-input
            :maxLength="128"
              :disabled="modalFlag == 'info'"
              size="small"
              placeholder=""
              v-model="addForm.companyTitle"
            />
          </a-form-model-item>
          <!-- 接收人姓名 -->
          <a-form-model-item
            prop="addresseeName"
            label="接收人姓名："
            style="width: 47% !important"
          >
            <a-input
            :maxLength="128"
              :disabled="modalFlag == 'info'"
              size="small"
              placeholder=""
              v-model="addForm.addresseeName"
            />
          </a-form-model-item>
          <!-- 电话号码 -->
          <a-form-model-item
            prop="telephone"
            label="电话号码："
            style="width: 47% !important"
          >
            <a-input
            :maxLength="128"
              size="small"
              :disabled="modalFlag == 'info'"
              placeholder=""
              v-model="addForm.telephone"
            />
          </a-form-model-item>
          <!-- 国家 -->
          <a-form-model-item
            prop="countryText"
            label="国家："
            style="width: 47% !important"
          >
            <a-select
              allowClear
              placeholder="请选择国家"
              :disabled="modalFlag == 'info'"
              size="small"
              show-search
              option-filter-prop="children"
              :filter-option="filterOption"
              @change="handleChangeState"
              v-model="addForm.countryId"
            >
              <a-select-option
                :value="item.id"
                v-for="item in state"
                :key="item.id"
                :name="item.name"
              >
                {{ item.name }}
              </a-select-option>
            </a-select>
          </a-form-model-item>
          <!-- 州市 -->
          <a-form-model-item
            prop="stateCityName"
            label="州市："
            style="width: 47% !important"
          >
            <a-select
              allowClear
              placeholder="请选择州/市"
              :disabled="modalFlag == 'info'"
              size="small"
              show-search
              option-filter-prop="children"
              :filter-option="filterOption"
              @change="handleChangeProvince"
              v-model="addForm.stateCityName"
            >
              <a-select-option
                :value="item.id"
                v-for="item in province"
                :key="item.id"
                :name="item.name"
              >
                {{ item.name }}
              </a-select-option>
            </a-select>
          </a-form-model-item>
          <!-- 城市 -->
          <a-form-model-item
            prop="city"
            label="城市："
            style="width: 47% !important"
          >
            <a-input
            :maxLength="128"
              size="small"
              placeholder=""
              v-model="addForm.city"
              :disabled="modalFlag == 'info'"
            />
          </a-form-model-item>
          <!-- 邮编 -->
          <a-form-model-item
            prop="postalCode"
            label="邮编："
            style="width: 47% !important"
          >
            <a-input
            :maxLength="128"
              size="small"
              placeholder=""
              v-model="addForm.postalCode"
              :disabled="modalFlag == 'info'"
            />
          </a-form-model-item>
          <!-- 详细地址 -->
          <a-form-model-item prop="fullAddress" label="详细地址：">
            <a-input
            :maxLength="128"
              size="small"
              placeholder=""
              :disabled="modalFlag == 'info'"
              v-model="addForm.fullAddress"
            />
          </a-form-model-item>
        </a-form-model>
      </a-tab-pane>

      <a-tab-pane
        key="2"
        style="padding: 20px"
        v-if="addForm.byTransferWarehousingOutApplyId"
      >
        <span slot="tab"> 2、转运清单 </span>
        <div class="order-top">
          <h3>转运清单</h3>
          <p style="margin-bottom: 5px" class="">SKU库存发货列表明细</p>

          <a-table
            style="margin-top: 5px"
            size="small"
            bordered
            :data-source="skuInfo"
            :pagination="false"
            :scroll="{ x: 1200, y: 180 }"
          >
            <a-table-column
              key="goodsBoxNo"
              data-index="goodsBoxNo"
              align="center"
              width="10%"
            >
              <span slot="title">装箱编号</span>
              <template slot-scope="text, record">
                {{ record.goodsBoxNo }}
              </template>
            </a-table-column>
            <a-table-column
              key="skuName"
              data-index="skuName"
              align="center"
              width="10%"
            >
              <span slot="title">商品名称</span>
              <template slot-scope="text, record">
                {{ record.skuName }}
              </template>
            </a-table-column>
            <a-table-column
              key="sku"
              data-index="sku"
              align="center"
              width="10%"
            >
              <span slot="title">SKU</span>
              <template slot-scope="text, record">
                {{ record.sku }}
              </template>
            </a-table-column>
            <a-table-column
              key="productTag"
              data-index="productTag"
              align="center"
              width="10%"
            >
              <span slot="title">标签</span>
              <template slot-scope="text, record">
                {{ record.productTag }}
              </template>
            </a-table-column>
            <a-table-column
              key="skuTotal"
              data-index="skuTotal"
              align="center"
              width="10%"
            >
              <span slot="title">SKU数量</span>
              <template slot-scope="text, record">
                {{ record.skuTotal }}
              </template>
            </a-table-column>
            <a-table-column
              key="boxTotal"
              data-index="boxTotal"
              align="center"
              width="15%"
            >
              <span slot="title">箱子数量</span>
              <template slot-scope="text, record">
                {{ record.boxTotal }}
              </template>
            </a-table-column>
            <!-- 操作 -->
            <a-table-column
              key="operation"
              data-index="operation"
              title="操作"
              width="5%"
              align="center"
            >
              <template slot-scope="text, record">
                <a-popconfirm
                  v-if="skuInfo.length && modalFlag != 'info'"
                  title="确定删除吗?"
                  okText="确定"
                  cancelText="取消"
                  @confirm="() => onDeleteSkuInfo(record, record.key)"
                >
                  <a
                    href="javascript:;"
                    style="
                      color: rgb(243, 56, 29);
                      border-bottom: 1px solid rgb(243, 56, 29);
                    "
                    >删除</a
                  >
                </a-popconfirm>
              </template>
            </a-table-column>
          </a-table>
        </div>
        <div class="order-top" style="margin-top: 15px">
          <p style="margin-bottom: 5px">转运货物列表</p>
          <a-table
            size="small"
            bordered
            :data-source="tranferGoods"
            :pagination="false"
            :scroll="{ x: 1200, y: 180 }"
          >
            <a-table-column
              key="transferNo"
              data-index="transferNo"
              align="center"
              width="8%"
            >
              <span slot="title">订单编号</span>
              <template slot-scope="text, record">
                {{ record.transferNo }}
              </template>
            </a-table-column>
            <a-table-column
              key="goodsBoxNo"
              data-index="goodsBoxNo"
              align="center"
              width="8%"
            >
              <span slot="title">货物编号</span>
              <template slot-scope="text, record">
                {{ record.goodsBoxNo }}
              </template>
            </a-table-column>
            <a-table-column
              key="customBoxNo"
              data-index="customBoxNo"
              align="center"
              width="8%"
            >
              <span slot="title">自定义编号</span>
              <template slot-scope="text, record">
                {{ record.customBoxNo }}
              </template>
            </a-table-column>
            <a-table-column
              key="skus"
              data-index="skus"
              align="center"
              width="8%"
            >
              <span slot="title">SKU</span>
              <template slot-scope="text, record">
                {{ record.skus }}
              </template>
            </a-table-column>
            <a-table-column
              key="sizes"
              data-index="sizes"
              align="center"
              width="10%"
            >
              <span slot="title">单位尺寸（cm）</span>
              <template slot-scope="text, record">
                {{ record.long + "*" + record.width + "*" + record.height }}
              </template>
            </a-table-column>
            <a-table-column
              key="boxTotal"
              data-index="boxTotal"
              align="center"
              width="10%"
            >
              <span slot="title">单位重量（kg）</span>
              <template slot-scope="text, record">
                {{ record.weight }}
              </template>
            </a-table-column>
            <a-table-column
              key="transportTotal"
              data-index="transportTotal"
              align="center"
              width="8%"
            >
              <span slot="title">转运数量</span>
              <template slot-scope="text, record">
                {{ record.transportTotal }}
              </template>
            </a-table-column>
            <!-- 操作 -->
            <a-table-column
              key="operation"
              data-index="operation"
              title="操作"
              width="5%"
              align="center"
            >
              <template slot-scope="text, record">
                <a-popconfirm
                  v-if="tranferGoods.length && modalFlag != 'info'"
                  title="确定删除吗?"
                  okText="确定"
                  cancelText="取消"
                  @confirm="() => onDeleteTransfer(record)"
                >
                  <a
                    href="javascript:;"
                    style="
                      color: rgb(243, 56, 29);
                      border-bottom: 1px solid rgb(243, 56, 29);
                    "
                    >删除</a
                  >
                </a-popconfirm>
              </template>
            </a-table-column>
          </a-table>
          <h3 style="margin: 15px 0 5px 0">物流运单及标签文件</h3>
          <div>
            <a-table
              size="small"
              bordered
              :data-source="fileTable"
              :pagination="false"
              :scroll="{ x: 1200, y: 180 }"
            >
              <a-table-column
                key="fileExplain"
                data-index="fileExplain"
                align="center"
                width="8%"
              >
                <span slot="title">文件描述说明</span>
                <template slot-scope="text, record">
                  {{ record.fileExplain }}
                </template>
              </a-table-column>
              <a-table-column
                key="filePath"
                data-index="filePath"
                align="center"
                width="8%"
              >
                <span slot="title">文件</span>
                <template slot-scope="text, record">
                  <a :href="record.filePath.url" target="_blank">{{
                    record.filePath.text
                  }}</a>
                </template>
              </a-table-column>
              <a-table-column
                key="auditState"
                data-index="auditState"
                align="center"
                width="8%"
              >
                <span slot="title">状态</span>
                <template slot-scope="text, record">
                  <span style="margin-right: 10px">{{
                    record.auditState
                  }}</span>
                  <a-checkbox
                    :disabled="
                      submitView == 'look' || record.auditState == '已查阅'
                    "
                    :defaultChecked="record.auditState == '已查阅'"
                    @change="(e) => onChangeAuditState(e, record)"
                  >
                  </a-checkbox>
                  <span>（勾选表示已查阅）</span>
                </template>
              </a-table-column>
              <!-- 操作 -->
              <a-table-column
                key="operation"
                data-index="operation"
                title="操作"
                width="5%"
                align="center"
              >
                <template slot-scope="text, record">
                  <a-popconfirm
                    v-if="fileTable.length && modalFlag != 'info'"
                    title="确定删除吗?"
                    okText="确定"
                    cancelText="取消"
                    @confirm="() => onDeleteFile(record)"
                  >
                    <a
                      href="javascript:;"
                      style="
                        color: rgb(243, 56, 29);
                        border-bottom: 1px solid rgb(243, 56, 29);
                        margin-right: 20px;
                      "
                      >删除</a
                    >
                  </a-popconfirm>
                  <!-- <a-upload
                    v-if="modalFlag != 'info'"
                    :beforeUpload="beforeUploads"
                    name="file"
                    :action="baseUrl + '/by-file/uploadFile'"
                    :headers="headers"
                    @change="info => handle(info, record)"
                    :showUploadList="false"
                  >
                    <a
                      style="
                color: #0000bf;
                border-bottom: 1px solid #0000bf;
              "
                      href="javascript:;"
                      >上传相关文件</a
                    >
                  </a-upload> -->
                </template>
              </a-table-column>
            </a-table>
          </div>
          <a-button
            type="primary"
            style="margin-top: 20px"
            v-if="addForm.auditState >= 4"
            @click="goService"
            >查看账单</a-button
          >
        </div>
      </a-tab-pane>
    </a-tabs>
    <ServiceModalReap />
  </a-modal>
</template>

<script>
import {
  TransferOut_state,
  TransferOut_Province,
  TransferOut_warehouse,
  TransferOutdel_housPdt,
  TransferOut_warehousingOccupy,
  TransferOut_addGoods,
  TransferOut_searchItem,
  TransferOut_delteInfo,
  TransferOut_searchGoodsList,
  TransferOut_fileList,
  TransferOut_audit,
  TransferOut_flieAudit,
  TransferOut_sendBill,
  TransferOut_getSkuList,
} from "@/apis/clientSide/OrderManage/TransferOut";
import { removefile } from "@/apis/common";
import ServiceModalReap from "@/components/serviceModal/ServiceModalReap";
import baseUrl from "@/utils/baseUrl";
export default {
  props: ["getTransferOutTableList", "getStateCount"],
  created() {
    this.getState();
    this.getWarehouseList();
  },
  components: {
    ServiceModalReap,
  },
  data() {
    return {
      submitView: "",
      //物流
      fileTable: [],
      //物流下拉
      logisticsOption: [
        { title: "原装箱发出", value: "0" },
        { title: "仓库装箱/打托", value: "1" },
      ],
      //物流方式
      logisticsTagfile: undefined,
      styleBack: {
        border: "1px solid #f00",
        borderRadius: "5px",
      },
      styleYes: {
        border: "1px solid #ccc",
        borderRadius: "5px",
      },
      columnWidth: 50,
      //搜索货物列表
      sreachGoogdData: {
        transferNo: null,
        goodsBoxNo: null,
        warehouseId: null,
      },
      //SKU库存发货列表明细
      skuInfo: [],
      //搜索出来的列表
      searchTransferData: [],
      //转运货物列表
      tranferGoods: [],

      activeKey: "1",
      addressIds: [{ key: "1", value: "1", titleName: "111" }],
      warehouses: [
        { value: "1", key: "1", titleName: "平台卡派自提" },
        { value: "2", key: "2", titleName: "仓库运单" },
        { value: "3", key: "3", titleName: "仓库卡派" },
        { value: "4", key: "4", titleName: "自有卡派运单" },
      ],
      visible: false,
      addFormRules: {
        title: [
          {
            required: true,
            message: "请填写转运标题！",
            trigger: "blur",
          },
        ],
      },
      addForm: {
        addressType: 1,
      },
      SKUchineseName: [],
      warehouseData: [],
      edit: false,
      loading: false,
      iconFlag: false,
      // 上传标杆
      imgUrl: "",
      uploadImgFlag: false,
      baseUrl,
      fileList: [],
      previewImage: "",
      previewVisible: false,
      //上传文件请求头
      headers: {
        authorization: "authorization-text",
        token: sessionStorage.getItem("tk"),
      },
      modalTitle: "",
      //模态框提交标杆
      modalFlag: "",
      // 国家
      state: [],
      //   省市区
      province: [],
      transferList: {},
      selectedRowKeys: [],
      submitFlag: false,
      passFlag: true,
    };
  },
  mounted() {
    this.editRow();
  },
  methods: {
    //打开服务项
    goService() {
      if (this.addForm.isServiceItem >= 1 && this.addForm.auditState == "4") {
        this.$bus.$emit(
          "reappearance",
          this.addForm,
          1,
          this.addForm.byTransferWarehousingOutApplyId,
          true
        );
      } else {
        this.$bus.$emit(
          "reappearance",
          this.addForm,
          1,
          this.addForm.byTransferWarehousingOutApplyId,
          false
        );
      }
    },
    async onChangeAuditState(e, record) {
      let res = await TransferOut_flieAudit(
        record.byTransferWarehousingOutApplyId,
        record.byTransferWarehousingOutTagfileId,
        record.revision
      );
      if (res.code == "10000") {
        if (e.target.checked) {
          record.auditState = "已查阅";
          e.target.disabled = true;
        }
      }
    },

    goBack() {
      this.activeKey = "1";
    },
    //查询库存列表
    async searchWarehousingList() {
      let { code, responseBody } = await TransferOut_warehousingOccupy(
        this.sreachGoogdData
      );
      if (code == "200") {
        this.searchTransferData = responseBody.records;
        this.searchTransferData.forEach((item) => {
          item.skus = item.skus.split(",");
        });
      }
    },
    async onSelectChange(selectedRowKeys, row) {
      if (row[0].transportTotal == undefined) {
        row = [];
        this.$message.error("请输入转运数量！");
        return false;
      }
      this.selectedRowKeys = selectedRowKeys;
      let params = {
        long: row[0].long,
        height: row[0].height,
        width: row[0].width,
        weight: row[0].weight,
        customBoxNo: row[0].customBoxNo,
        goodsBoxNo: row[0].goodsBoxNo,
        transferNo: row[0].transferNo,
        warehouseId: row[0].warehouseId,
        total: row[0].total,
        skus: row[0].skus.join(","),
        transportTotal: row[0].transportTotal,
      };
      let { code, responseBody } = await TransferOut_addGoods(
        this.addForm.byTransferWarehousingOutApplyId,
        row[0].transferWarehousingApplyId,
        row[0].transferWarehousingBoxId,
        params
      );
      if (code == "10000") {
        this.tranferGoods.push(responseBody);
      }
      this.selectedRowKeys = [];
      this.searchWarehousingList();
    },
    //删除每一行商品
    onDeleteSkuInfo(record) {
      console.log(record);
    },
    //删除每一行货物
    onDeleteTransfer(record) {
      this.tranferGoods.forEach(async (item, index) => {
        if (
          item.byTransferWarehousingOutRecordId ===
          record.byTransferWarehousingOutRecordId
        ) {
          let { code } = await TransferOut_delteInfo(
            record.byTransferWarehousingOutApplyId,
            record.byTransferWarehousingOutRecordId
          );
          if (code == "10000") {
            this.tranferGoods.splice(index, 1);
          }
        }
      });
    },

    changeTab(activeKey) {
      this.activeKey = activeKey;
    },
    //关闭模态框
    cancel() {
      this.visible = false;
      this.addForm = {};
      this.activeKey = "1";
      this.tranferGoods = [];
      this.skuInfo = [];
      this.sreachGoogdData = {
        transferNo: null,
        goodsBoxNo: null,
        warehouseId: null,
      };
      this.searchTransferData = [];
    },
    //物流安排改变
    ChangeWarehouses(value, option) {
      this.addForm.logisticsName = option.data.attrs.name;
    },
    //删除图片
    async delFile() {
      let { code } = await removefile(this.imgUrl.split(","));
      if (code === "10000") {
        this.imgUrl = "";
        this.addForm.ectnFile = "";
      }
    },
    handleCancel() {
      this.previewVisible = false;
    },

    // 出库仓库更改
    async handleChangeWarehouse(value, option) {
      let { code, responseBody } = await TransferOutdel_housPdt(value);
      if (code === "200") {
        this.SKUchineseName = responseBody;
      }
      this.addForm.warehouseName = option.data.attrs.name;
      this.addForm.warehouseId = value * 1;
      this.sreachGoogdData.warehouseId = value * 1;
    },
    // 地区更改
    handleChangeProvince(value, option) {
      if (option != undefined) {
        this.addForm.stateCityName = option.data.attrs.name;
      } else {
        this.addForm.stateCityName = null;
      }
    },
    //签收选择
    onChangeSign(e) {
      this.signFlag = e.target.checked;
      this.addForm.sign = e.target.checked ? 1 : 0;
    },
    // 物流运单
    onChangeLogistics(e) {
      this.Logistics = e.target.checked;
      this.addForm.isEctn = e.target.checked ? 1 : 0;
    },

    // 国家下拉
    async handleChangeState(value, option) {
      if (option != undefined) {
        this.addForm.countryText = option.data.attrs.name;
      } else {
        this.addForm.countryText = null;
      }
      if (value != undefined) {
        let { code, responseBody } = await TransferOut_Province(value);
        if (code === "200") {
          this.province = responseBody;
        }
      }
    },
    filterOption(input, option) {
      return (
        option.componentOptions.children[0].text
          .toLowerCase()
          .indexOf(input.toLowerCase()) >= 0
      );
    },
    //获取国家接口
    async getState() {
      let { code, responseBody } = await TransferOut_state();
      if (code === "200") {
        this.state = responseBody;
      }
    },
    //获取仓库列表 获取销售平台  物流商
    async getWarehouseList() {
      let { code, responseBody } = await TransferOut_warehouse({
        warehousePid: 0,
      });
      if (code === "200") {
        this.warehouseData = responseBody;
      }
    },
    //点击提交或修改
    async handleOk(flag) {
      this.loading = true;
      this.passFlag = true;
      if (flag == "pass") {
        this.fileTable.forEach((item) => {
          if (item.auditState == "未查阅") {
            this.passFlag = false;
          }
        });
        if (this.passFlag) {
          let res = await TransferOut_audit(
            this.addForm.byTransferWarehousingOutApplyId,
            this.addForm.revision,
            "3"
          );
          if (res.code == "10000") {
            this.getTransferOutTableList();
            this.getStateCount();
            this.loading = false;
            this.visible = false;
          }
        } else {
          this.$message.error("请先查阅文件后再进行审核！");
          return false;
        }
      }
      if (flag == "no") {
        let { code } = await TransferOut_audit(
          this.addForm.byTransferWarehousingOutApplyId,
          this.addForm.revision,
          "0"
        );
        if (code == "10000") {
          this.getTransferOutTableList();
          this.getStateCount();
          this.visible = false;
        }
      }
      if (flag == "sendBill") {
        let { code } = await TransferOut_sendBill(
          this.addForm.byTransferWarehousingOutApplyId,
          this.addForm.revision
        );
        if (code == "10000") {
          this.getTransferOutTableList();
          this.getStateCount();
          this.visible = false;
          this.loading = false;
        }
      }
    },
    //修改每一行数据
    editRow() {
      this.$bus.$off("TransferOutRowData");
      this.$bus.$on("TransferOutRowData", async (rowData, flag, auditState) => {
        this.activeKey = "1";
        this.submitView = auditState;
        let { code, responseBody } = await TransferOut_searchItem(
          rowData.byTransferWarehousingOutApplyId
        );
        if (code == "200") {
          this.addForm = responseBody;
          this.addForm.addressType = this.addForm.addressType * 1;
          this.sreachGoogdData.warehouseId = this.addForm.warehouseId;
          if (flag === "edit") {
            this.modalTitle = "修改出库订单";
            this.modalFlag = "edit";
            this.visible = true;
            this.edit = true;
          } else if (flag === "info") {
            this.modalTitle = "查看出库订单详情";
            this.modalFlag = "info";
            this.visible = true;
          }
          this.getSkuInfo();
          this.searchGoodsList(rowData);
          this.searchFileList(rowData);
        }
      });
    },
    //查询货物列表
    async searchGoodsList(rowData) {
      let { code, responseBody } = await TransferOut_searchGoodsList(
        rowData.byTransferWarehousingOutApplyId
      );
      if (code == "200") {
        this.tranferGoods = responseBody;
      }
    },
    //查询文件
    async searchFileList(rowData) {
      let { code, responseBody } = await TransferOut_fileList(
        rowData.byTransferWarehousingOutApplyId
      );
      if (code == "200") {
        responseBody.forEach((item) => {
          if (item.auditState == "1") {
            item.auditState = "未查阅";
          } else {
            item.auditState = "已查阅";
          }
        });
        this.fileTable = responseBody;
        this.fileTable.forEach((item) => {
          item.filePath = JSON.parse(item.filePath);
        });
      }
    },
    //获取sku发货列表
    async getSkuInfo() {
      let res = await TransferOut_getSkuList(
        this.addForm.byTransferWarehousingOutApplyId
      );
      if (res.code == "200") {
        this.skuInfo = res.responseBody;
      }
    },
  },
  computed: {
    columns() {
      return [
        {
          title: "商品名称",
          dataIndex: "skuName",
          align: "center",
          // scopedSlots: { customRender: "selfClassifyName" },
          ellipsis: true,
          width: "20%",
        },
        {
          title: "SKU",
          dataIndex: "skus",
          align: "center",
          width: "20%",
          ellipsis: true,
          scopedSlots: { customRender: "skus" },
        },
        {
          title: "标签",
          dataIndex: "productTag",
          scopedSlots: { customRender: "productTag" },
          align: "center",
          width: "20%",
          ellipsis: true,
        },
        {
          title: "数量",
          dataIndex: "inputNumber",
          scopedSlots: { customRender: "inputNumber" },
          align: "center",
          width: "20%",
          ellipsis: true,
        },
        {
          title: "操作",
          dataIndex: "action",
          scopedSlots: { customRender: "action" },
          align: "center",
          width: 120,
        },
      ];
    },
  },
};
</script>

<style lang="less" scoped>
/deep/.ant-modal {
  .ant-modal-content {
    .ant-modal-footer {
      display: flex;
      justify-content: center;
    }
  }
}
/deep/.ant-modal-footer {
  button {
    margin-right: 10px;
  }
}
.zxmx {
  display: flex;
  margin-top: 15px;
  padding: 0 15%;
  margin-bottom: 15px;
  align-content: center;
  flex-wrap: wrap;
  /deep/.ant-form-item {
    width: 100%;
    margin-right: 3%;
    .ant-form-item-label {
      width: 100px !important;
      label {
        display: block;
      }
    }
    .ant-form-item-control-wrapper {
      flex: 1;
    }
  }
  > div {
    display: flex;
    margin-right: 15px;
  }
}
.orderSearch {
  margin: 10px 0 5px 0;
  display: flex;
  align-items: center;
  > div {
    display: flex;
    margin-right: 10px;
    align-items: center;
    span {
      width: 100px;
      display: block;
    }
  }
  > div:first-child {
    span {
      width: 200px;
    }
  }
}
</style>
